package com.handsome.职责链模式;

/**
 *
 * 职责链模式解决OA审批问题
 * @author niechun
 * @date 2023/3/27 21:03
 */
public class Client {
    public static void main(String[] args) {
        PurchaseRequest purchaseRequest=new PurchaseRequest(1,3000f,10);
        DepartmentApproveHandler departmentApproveHandler = new DepartmentApproveHandler("主任");
        CollegeApproveHandler collegeApproveHandler = new CollegeApproveHandler("院长");
        VicePrincipalApproveHandler vicePrincipalApproveHandler = new VicePrincipalApproveHandler("副校长");
        PrincipalApproveHandler principalApproveHandler = new PrincipalApproveHandler("校长");
        //需要设置下一个handler 可以形成一个环状也可以形成一个链条
        departmentApproveHandler.setHandler(collegeApproveHandler);
        collegeApproveHandler.setHandler(vicePrincipalApproveHandler);
        vicePrincipalApproveHandler.setHandler(principalApproveHandler);
        principalApproveHandler.setHandler(departmentApproveHandler);

        principalApproveHandler.processRequest(purchaseRequest);

    }
}
